package wangjg.xuexiban.activity;

import wangjg.xuexiban.util.ResoureCache;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.ScrollView;

public class BasicActivity extends Activity {

	private int screenWidth = -1;
	private int screenHeight = -1;
	
	protected ResoureCache rc = new ResoureCache();
	
	protected int getScreenWidth(){
		if(screenWidth==-1){
			WindowManager manage = getWindowManager();
			Display display = manage.getDefaultDisplay();
			screenWidth = display.getWidth();	
		}
		return screenWidth;
	}
	
	protected int getScreenHeight(){
		WindowManager manage = getWindowManager();
		Display display = manage.getDefaultDisplay();
		screenHeight = display.getHeight();
		return screenHeight;
	}

	protected View inflate(int resource) {
		LayoutInflater layoutInflater = LayoutInflater.from(this);
		View view = layoutInflater.inflate(resource, null);
		return view;
	}

	protected void scrollDown(final ScrollView sv) {
		sv.post(new Runnable() {
			public void run() {
				sv.fullScroll(View.FOCUS_DOWN);
			}
		});
	}

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.i(this.getClass().getName(), "onCreate...");
	}
	
	protected void onStart() {
		super.onStart();
		Log.i(this.getClass().getName(), "onStart...");
	}
	
    protected void onPause() {
    	super.onPause();
    	Log.i(this.getClass().getName(), "onPause...");
    }
    
    protected void onStop() {
    	super.onStop();
    	Log.i(this.getClass().getName(), "onStop...");
    }
    
    protected void onDestroy() {
    	super.onDestroy();
    	Log.i(this.getClass().getName(), "onDestroy...");
    }
}
